import legacy from '@vitejs/plugin-legacy'
import vue from '@vitejs/plugin-vue'
import path from 'path'
import { defineConfig } from 'vite'

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [
    vue(),
    legacy()
  ],
   server: {
    proxy: {
      '/api': {
        // target: 'http://localhost/user',  // 目标服务器地址
        target:'http://4221xv6hk847.vicp.fun/',
        changeOrigin: true,  // 更改请求头中的 Origin 字段
        secure: false,  // 忽略自签名证书错误
        rewrite: path => path.replace(/^\/api/, '')  // 重写路径
      }
    }
  },
  resolve: {
    alias: {
      '@': path.resolve(__dirname, './src'),
    },
  },
  test: {
    globals: true,
    environment: 'jsdom'
  }
})
